;*****************************************************
; 	Copyright (C) SEIKO EPSON CORP. 1997-2001
;	All rights Reserved
;
;	File name : strcmp.s
;	Function  :
;	       This is strcmp function
;	Revision  :
;		1997/03/25	V.Chan start
;		2001/12/06	T.Tazaki for GNU33(Linux)
;*****************************************************

;*****************************************************
; strcmp
;	compare src1 and src2 (0 terminated)
;	result > 0	if src1 > src2
;	result < 0	if src1 < src2
;	result = 0	if src1 = src2
;
; arguments : %r6:src1 addr, %r7:src2 addr
; return    : %r4:result
;*****************************************************

	.section .text
	.align 1
	.global strcmp
	.type	strcmp,@function

strcmp:
	ld.w	%r11, 1		; initialize byte
			
strcmp_loop:
	cmp		%r11, 0		; exit if both bytes = 0
	jreq	strcmp_ret
	ld.ub	%r10, [%r6]+	; load byte
	ld.ub	%r11, [%r7]+	; load byte
	sub		%r10, %r11
	jreq	strcmp_loop

strcmp_ret:
	ret.d
	ld.w	%r4, %r10

